Skip to content

BUG: fix scipy backend pickling after multiple opens#11339

Closed
hansu650 wants to merge 1 commit into
pydata:mainfrom
hansu650:bug/scipy-backend-pickle
Closed

BUG: fix scipy backend pickling after multiple opens#11339
hansu650 wants to merge 1 commit into
pydata:mainfrom
hansu650:bug/scipy-backend-pickle

Conversation

@hansu650
Copy link
Copy Markdown

Closes #11323.

This fixes a scipy backend pickling regression when multiple datasets are opened
from file-like objects in the same process.

The scipy backend registers a pickle-visible wrapper class for file-like objects.
Re-registering that class on every open can make an earlier dataset refer to a
class object that no longer matches the registered pickle target. This change
registers the wrapper once and reuses it for later file-like opens.

The regression test opens two scipy-backed datasets from the same in-memory
NetCDF payload and verifies that the first dataset can still be pickled and
unpickled.

Validation:

  • python -m pytest xarray/tests/test_backends.py -k "scipy and pickle"
  • python -m pytest xarray/tests/test_backends.py -k "scipy"
  • python -m ruff check xarray/backends/scipy_.py xarray/tests/test_backends.py
  • git diff --check

AI assistance:
I used ChatGPT/Codex to help inspect the issue and plan a small local patch. I reviewed the final diff and test results myself and understand the submitted changes.

@hansu650
Copy link
Copy Markdown
Author

Thanks for the CI feedback. I'm going to close this for now because I don't have time to follow up on the Mypy failure properly. Sorry for the noise.

@hansu650 hansu650 closed this by deleting the head repository May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2026.4.0 breaks pickling with backends.scipy_

1 participant